<?php
Class PointsAction extends Action{
	public function user(){
		$user['id'] =$this->userid = intval(I('id'));
		$this->user = $user = M('User')->where($user)->find();//当前用户的一些基本信息

		$openid=$user['openid'];
		import('ORG.Util.EditPage');
		$count = M()->Table('box_user_points a')->join("box_user_points_rule b on a.type=b.id")->field('a.type,a.points,a.addtime,b.name,b.add')->where("a.openid='{$openid}' and is_frozen=1")->count();
		$Page = new Page($count,10);
        $Page->setConfig('theme',"<ul class='pagination'><li><a>%totalRow% %header% %nowPage%/%totalPage% 页</a></li><li>%upPage%</li><li>%first%</li><li>%prePage%</li><li>%linkPage%</li><li>%nextPage%</li><li>%end%</li><li>%downPage%</li>".$gopagenu."</ul>");
		$this->page = $Page->show();
        //$this->discuss =  M('UserPoints')->where($condition)->order("id desc")->limit($Page->firstRow.','.$Page->listRows)->select();
        $list = M()->Table('box_user_points a')->join("box_user_points_rule b on a.type=b.id")->field('a.type,a.points,a.addtime,b.name,b.add')->where("a.openid='{$openid}' and is_frozen=1")->limit($Page->firstRow.','.$Page->listRows)->select();
        foreach ($list as $key => $value) {
            if($value['add']==2){
                $value['points']="-".$value['points'];
            }else{
                $value['points']="+".$value['points'];
            }
            $value['addtime']=date('Y.m.d',strtotime($value['addtime']));
        }

        $this->points = $list;

        $this->currentpage = $Page->firstRow + 1; 	
        $this->display();
	}
}